﻿// ***********************************************************************
// Assembly         : STX.Domain
// Author           : seven.x
// Created          : 12-26-2013
//
// Last Modified By : seven.x
// Last Modified On : 12-26-2013
// ***********************************************************************
// <copyright file="EntityBase.cs" company="驰创数码">
//     Copyright (c) 驰创数码. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************

using System;
using System.Linq;

namespace STX.Domain
{

    /// <summary>
    /// Class BaseEntity.
    /// </summary>
    public abstract class BaseEntity
    {
        /// <summary>
        /// Gets or sets the unique identifier.
        /// </summary>
        /// <value>The unique identifier.</value>
        public int Id { get; set; }

        /// <summary>
        /// Initializes a new instance of the <see cref="BaseEntity" /> class.
        /// </summary>
        protected BaseEntity()
        {
            var t = this.GetType();
            var pis = t.GetProperties();
            foreach (var pi in pis.Where(pi => pi.PropertyType == typeof (DateTime)))
            {
                pi.SetValue(this, DateTime.Now, null);
            }
        }
    }
}
